import { BaseSkill } from '../BaseSkill';
import { DamageType, SkillType } from '../../types';
import { General } from '../../models/General';
import { Battle } from '../../models/Battle';

export class FanJianJi extends BaseSkill {
  private readonly REDUCTION_VALUE = 0.2;  // 20% 伤害减免
  private readonly REFLECT_VALUE = 0.2;    // 20% 伤害反弹

  constructor() {
    super(
      'fanJianJi',
      '反间计',
      SkillType.Passive,
      DamageType.Strategy,
      1.0,        // 100% 触发概率
      3,          // 3回合CD
      2           // 2回合持续
    );
  }

  execute(source: General, battle: Battle): void {
    if (!this.canUse() || Math.random() > this.probability) return;

    // 添加伤害减免效果
    source.addEffect({
      type: 'damageReduction',
      value: this.REDUCTION_VALUE,
      duration: this.duration,
      stackable: false,
      source: this.id,
      timestamp: Date.now()
    });

    // 添加伤害反弹效果
    source.addEffect({
      type: 'damageReflect',
      value: this.REFLECT_VALUE,
      duration: this.duration,
      stackable: false,
      source: this.id,
      timestamp: Date.now()
    });

    this.startCooldown();
  }
}
